﻿//08.Write a program that calculates the greatest common divisor (GCD) 
//of given two numbers. Use the Euclidean algorithm (find it in Internet).

using System;

namespace GCD
{
    class GCD
    {
        static void Main()
        {
            Console.Write("Enter the first number a = ");
            int a = int.Parse(Console.ReadLine());
            Console.Write("Enter the second number b = ");
            int b = int.Parse(Console.ReadLine());

            int greatestCommonDivisor = 1;
            int c = 0;

            if (a > b)
            {
                c = b;
            }
            else if (a < b)
            {
                c = a;
            }
            else
            {
                c = a;
            }

            for (int i = 1; i <= c; i++)
            {
                if (a % i == 0 && b % i == 0)
                {
                    greatestCommonDivisor = i;
                }
            }
            Console.WriteLine("GCD ({0},{1}) = {2}.", a, b, greatestCommonDivisor);
        }
    }
}
